import { UserLayout, BasicLayout, RouteView, PageView } from '@/components/layouts'

export const asyncRouterMap = [

  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '首页' },
    redirect: '/dashboard',
    children: [
      // dashboard
      {
        path: '/dashboard',
        name: 'dashboard',
        component: () => import('@/views/dashboard/Workplace'),
        meta: { title: '仪表盘', icon: 'dashboard', role: [ 'super', 'admin', 'manager' ] },
      },

      // goods
      {
        path: '/goods',
        name: 'goods',
        component: PageView,
        redirect: '/goods/list',
        meta: { title: '商品管理', icon: 'form', role: [ 'admin' ] },
        children: [
          {
            path: '/goods/list',
            name: 'GoodsList',
            component: () => import(/* webpackChunkName: "goods" */ '@/views/goods/GoodsList'),
            meta: { title: '商品列表', role: [ 'admin' ] }
          },
          {
            path: '/goods/add',
            name: 'AddGoods',
            component: () => import(/* webpackChunkName: "goods" */ '@/views/goods/AddGoods'),
            meta: { title: '新增商品', role: ['super', 'admin'] }
          },
          {
            path: '/goods/:id/edit',
            name: 'EditGoods',
            component: () => import(/* webpackChunkName: "goods" */ '@/views/goods/EditGoods'),
            hidden: true,
            meta: { title: '更新商品', role: ['super', 'admin'] }
          }
        ]
      },

      // order
      {
        path: '/order',
        name: 'order',
        component: PageView,
        redirect: '/order/list',
        meta: { title: '订单管理', icon: 'table', role: [ 'admin' ] },
        children: [
          {
            path: '/order/list',
            name: 'OrderList',
            component: () => import(/* webpackChunkName: "order" */ '@/views/order/OrderList'),
            meta: { title: '订单列表', role: [ 'admin' ] }
          },
          {
            path: '/order/:id',
            name: 'ViewOrder',
            component: () => import(/* webpackChunkName: "order" */ '@/views/order/Order'),
            hidden: true,
            meta: { title: '订单详情', role: ['super', 'admin'] }
          }
        ]
      },

      // user
      {
        path: '/user',
        name: 'user',
        component: RouteView,
        redirect: '/user/list',
        meta: { title: '用户管理', icon: 'user', role: [ 'admin' ] },
        children: [
          {
            path: '/user/list',
            name: 'UserList',
            component: () => import(/* webpackChunkName: "user" */ '@/views/user/UserList'),
            meta: { title: '用户列表', role: [ 'admin' ] }
          }
        ]
      },

      // setting
      {
        path: '/setting',
        name: 'setting',
        component: PageView,
        redirect: '/setting/branch',
        meta: { title: '设置管理', icon: 'setting', role: [ 'admin' ] },
        children: [
          {
            path: '/setting/branch',
            name: 'Branch',
            component: () => import(/* webpackChunkName: "setting" */ '@/views/setting/Branch'),
            meta: { title: '店铺管理', role: ['super', 'admin'] }
          },
          {
            path: '/setting/category',
            name: 'Category',
            component: () => import(/* webpackChunkName: "setting" */ '@/views/setting/Category'),
            meta: { title: '分类管理', role: ['super', 'admin'] }
          },
          {
            path: '/setting/brand',
            name: 'Brand',
            component: () => import(/* webpackChunkName: "setting" */ '@/views/setting/Brand'),
            meta: { title: '品牌管理', role: ['super', 'admin'] }
          },
          {
            path: '/setting/banner',
            name: 'Banner',
            component: () => import(/* webpackChunkName: "setting" */ '@/views/setting/Banner'),
            meta: { title: '轮播图管理', role: ['super', 'admin'] }
          }
        ]
      },
      // account
      {
        path: '/account',
        component: RouteView,
        name: 'account',
        hidden: true,
        meta: { title: '个人页', icon: 'user', keepAlive: true, role: [ 'super', 'admin', 'manager' ] },
        children: [
          {
            path: '/account/center',
            name: 'center',
            component: () => import('@/views/account/Center'),
            meta: { title: '个人中心', keepAlive: true, role: [ 'super', 'admin', 'manager' ] }
          },
          {
            path: '/account/change',
            name: 'change',
            component: () => import('@/views/account/ChangePass'),
            meta: { title: '修改密码', keepAlive: true, role: [ 'super', 'admin', 'manager' ]  },
          },
        ]
      },
      // manage
      {
        path: '/manage',
        component: RouteView,
        name: 'manage',
        meta: { title: '兑换管理', icon: 'user', keepAlive: true, role: [ 'manager' ] },
        children: [
          {
            path: '/manage/recharge',
            name: 'recharge',
            component: () => import('@/views/manage/Recharge'),
            meta: { title: '娃娃充值', role: [ 'manager' ] }
          },
          {
            path: '/manage/exchange',
            name: 'exchange',
            component: () => import('@/views/manage/Exchange'),
            meta: { title: '娃娃兑换', role: [ 'manager' ]  },
          },
        ]
      }
    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/auth',
    component: UserLayout,
    redirect: '/auth/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/Login')
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/404')
  },

]
